from django.utils import timezone
from django.contrib.auth.models import AbstractUser
from django.db import models

# Create your models here.
class Clazz(models.Model):
    name = models.CharField(max_length=100,db_comment="班级名")
    duration = models.FloatField(db_comment="课程时长")
    mange_name = models.CharField(max_length=100,db_comment="班主任")
    start_time = models.DateTimeField(db_comment="开班时间")
    state = models.BooleanField(db_comment="班级状态",default=False)
    create_time = models.DateTimeField(db_comment="录入时间",default=timezone.now,blank=True,null=True)
    update_time = models.DateTimeField(db_comment="修改时间",blank=True,null=True)
    delete_time = models.DateTimeField(blank=True,null=True,db_comment="删除时间")
    is_delete = models.BooleanField(db_comment="是否被删除",default=False)
    class Meta:
        db_table = 'tb_clazz'

class User(AbstractUser):
    #维护和班级的关系
    clazz = models.ForeignKey(to = Clazz,on_delete=models.CASCADE,blank=True,null=True)
    class Meta(AbstractUser.Meta):
        db_table = 'tb_user'
        swappable = 'TB_USER_MODEL'